
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.soldier.dto.PlacementBatchBSearcher;
import com.insigma.business.qrcode.soldier.dto.PlacementBatchDTO;
import com.insigma.business.qrcode.soldier.entity.PlacementBatchDO;
import com.insigma.business.qrcode.soldier.request.PlacementBatchInsertRequest;
import com.insigma.business.qrcode.soldier.request.PlacementBatchSearchRequest;
import com.insigma.business.qrcode.soldier.request.PlacementBatchUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class PlacementBatchProviderConverter extends AbstractConverter<PlacementBatchDTO, PlacementBatchDO> {

    private final static PlacementBatchProviderConverter placementBatchConverter = new PlacementBatchProviderConverter();

    private PlacementBatchProviderConverter(){}


    public static PlacementBatchBSearcher convertRequestSO2Searcher(final PlacementBatchSearchRequest request){
        final PlacementBatchBSearcher placementBatchBSearcher = new PlacementBatchBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,placementBatchBSearcher);
        return placementBatchBSearcher;
    }

    
    public static PlacementBatchDO convertRequestUO2DO(final PlacementBatchUpdateRequest placementBatchUpdateRequest) {
        final PlacementBatchDO placementBatchDO = new PlacementBatchDO();
        BeanUtils.copyProperties(placementBatchUpdateRequest,placementBatchDO);
        
        return placementBatchDO;
    }

    
    public static PlacementBatchDO convertRequestIO2DO(final PlacementBatchInsertRequest placementBatchInsertRequest) {
        final PlacementBatchDO placementBatchDO = new PlacementBatchDO();
        BeanUtils.copyProperties(placementBatchInsertRequest,placementBatchDO);
        return placementBatchDO;
    }

    
    public static List<PlacementBatchDTO> convertResponseDOList2DTOList(final List<PlacementBatchDO> placementBatchDOList){
        return placementBatchConverter.convertGenericResponseDOList2DTOList(placementBatchDOList);
    }

    
    public static PlacementBatchDTO convertResponseDO2DTO(final PlacementBatchDO placementBatchDO){
        return placementBatchConverter.convertGenericResponseDO2DTO(placementBatchDO);
    }

    
    @Override
    protected PlacementBatchDTO doConvertResponseDO2DTO(PlacementBatchDO placementBatchDO) {
        final PlacementBatchDTO placementBatchDTO = new PlacementBatchDTO();
        try {
            BeanUtils.copyProperties(placementBatchDO, placementBatchDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return placementBatchDTO;
    }

}
